package com.xbongbong.formula.qlexpress.operator.date;

import com.ql.util.express.Operator;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.enums.ErrorCodeEnum;
import com.xbongbong.pro.enums.errorcodes.BusinessRuleErrorCodeEnum;

import java.util.Date;
import java.util.Objects;

/**
 * 返回今天的日期，格式为:yyyy-MM-dd
 * @author 吴峰
 * @version v1.0
 * @date 2019/12/30 17:05
 * @since v1.0
 */
public class OperatorToday extends Operator {


    public OperatorToday(String name){
        this.name = name;
    }

    public OperatorToday(String aliasName, String aName, String errorInfo){
        this.aliasName = aliasName;
        this.name = aName;
        this.errorInfo = errorInfo;
    }


    /**
     * 语法：TODAY()
     * 说明：返回今天的日期，格式为:yyyy-MM-dd
     * 例如：客户跟进需要多次记录填写时间，通过TODAY函数自动填入【日期】。
     * @param list
     * list[0] 起始时间
     * list[1] 结束时间
     * @return
     * @throws Exception
     */
    @Override
    public Object executeInner(Object[] list) throws XbbException {
        if (Objects.isNull(list)) {
            throw new XbbException(BusinessRuleErrorCodeEnum.API_ERROR_261007);
        }
        return DateTimeUtil.getInt();
    }

}
